/*********************************************************************
 *
 *  Copyright (C) 1997 Acer Labs, Inc.  All Rights Reserved.
 *
 *  File:   filename
 *
 *  Contents:    Abstract and description of the contents of this file.
 *
 *  History:
 *   Date   By  Reason
 *   ====   ==  ======
 *    2007/09/13  Xing for DTVCC
 *********************************************************************/
#ifndef __LLD_VBI_M3327_ATSC_DTVCC_H__
#define __LLD_VBI_M3327_ATSC_DTVCC_H__


/*******************
* INCLUDE FILES    *
********************/



/*******************
* EXPORTED MACROS  *
********************/
//Constant Macro
#define 	INFO_TEXT			0X00
#define 	CAPTION_ROLL_UP	0X01
#define 	CAPTION_POP_ON	0X02
#define 	CAPTION_PAINT_ON	0X03
#define MAX_CHANNEL_DATA_SIZE 127 //xing 20070522 for DTVCC start
#define MAX_SERVICE_DATA_SIZE 31 //xing 20070522 for DTVCC start
#define	RESUME_CAPTION_LOADING		0X0
#define	BACKSPACE						0X1

#define	DELETE_TO_END_OF_ROW		0X4
#define	ROLLUP_CAPTION_2ROW			0X5
#define	ROLLUP_CAPTION_3ROW			0X6
#define	ROLLUP_CAPTION_4ROW			0X7
#define	FLASH_ON						0X8
#define	RESUME_DIRECT_CAPTIONING		0X9
#define	TEXT_RESTART					0XA
#define	RESUME_TEXT_DISPLAY			0XB
#define	ERASE_DISPLAYED_MEMORY		0XC
#define	CARRIAGE_RETURN				0XD
#define	ERASE_NONDISPLAYED_MEMORY	0XE
#define	END_OF_CAPTION				0XF

#define TransBCDtoWinBit(Num)  (Num == 0? 0: (0x01 << Num))
#define A(P)  ((P&0xc0)>>6)
#define R(P)  ((P&0x30)>>4)
#define G(P)  ((P&0x0c)>>2)
#define B(P)  (P&0x03)

struct CDFWcmd
{
	UINT8 CC_WindowsID;
       UINT8 CC_WindowsPriority;
       UINT8 CC_WindowsAnchorPoint;
	UINT8 CC_WindowsRelPos;
	UINT8 CC_WindowsAnchorVer;
	UINT8 CC_WindowsAnchorHor;
	UINT8 CC_WindowsRowCont;
	UINT8 CC_WindowsColumnCont;	
	UINT8 CC_WindowsColumnLock;
	UINT8 CC_WindowsRowLock;
       UINT8 CC_Windowsvisible;
	UINT8 CC_WindowsPenStyleID;
	UINT8 CC_WindowsWinStyleID;
};

struct CSWAcmd
{
	UINT8 CC_WindowsJustify;
	UINT8 CC_WindowsPrintDir;
	UINT8 CC_WindowsScrollDir;
	UINT8 CC_WindowsWordWrap;
	UINT8 CC_WindowsDisplayEffect;
	UINT8 CC_WindowsEffectDir;
	UINT8 CC_WindowsEffectSpeed;
	UINT8 CC_WindowsAttFillColor;
	UINT8 CC_WindowsAttFillOpacity;
	UINT8 CC_WindowsAttBorderType;
	UINT8 CC_WindowsAttBorderColor;

};

struct CSPAcmd
{
	UINT8 CC_WinPenAttPenSize;//CC_WindowsPenSize;
	UINT8 CC_WinPenAttFontStyle;//WindowsFontStyle;
	UINT8 CC_WinPenAttTextTag;//WindowsTextTag;
	UINT8 CC_WinPenAttOffset;//WindowsOffset;
	UINT8 CC_WinPenAttItalics;//WindowsItalics;
	UINT8 CC_WinPenAttUnderline;//WindowsUnderline;
	UINT8 CC_WinPenAttEdgeType;//WindowsEdgeType;
};

struct CSPCcmd
{
	UINT8 FG_Color;
	UINT8 FG_Opacity;
	UINT8 BG_Color;
	UINT8 BG_Opacity;
	UINT8 ED_Color;
};

struct CSPLcmd
{
	UINT8 PenRow;//gCC_WindowsRow;
	UINT8 PenColumn;//gCC_WindowsColumn;

};

	
struct CCWindow
{
	struct CDFWcmd CDefWin;
	struct CSWAcmd CSetWinAtt;
	BOOL CC_WindowsHideWin;
	BOOL CC_WindowsDisplayWin; 
	struct CSPAcmd CSetPenAtt;
	struct CSPCcmd CSetPenColor;
	struct CSPLcmd CSetPenLoc;	
	UINT8 pos_x;
	UINT8 pos_y;
};


struct caption_channel_packet
{
	UINT8 sequence_number:2;
	UINT8 packet_size:6;
	UINT8 Packet_data[MAX_CHANNEL_DATA_SIZE];
	
};

struct extend_service_block
{
	UINT8 block_size:5;
	UINT8 service_number:3;
	UINT8 extended_service_number:6;
	UINT8 null_fill:2;	
	UINT8 Block_data[MAX_SERVICE_DATA_SIZE];

};

struct service_block
{
	UINT8 block_size:5;
	UINT8 service_number:3;	
	UINT8 Block_data[MAX_SERVICE_DATA_SIZE];

};

//Function Macro
#define DTVCC_DEBUG
#ifdef DTVCC_DEBUG
//debug message
#define psoc_printf(...)//soc_printf //(...) //parsing data
#define xsoc_printf(...)
#define cc_printf(...)// soc_printf //command 
#define dtvcc_printf(...)
#define RGBsoc_printf(...)//color system
#define soc_printf(...)// libc_printf

//debug message end
#else
#define psoc_printf(...)  	do{}while(0)
#define xsoc_printf(...) 	do{}while(0)
#define cc_printf(...) 		do{}while(0)
#define dtvcc_printf(...) 	do{}while(0)
#define RGBsoc_printf(...) 	do{}while(0)
#define soc_printf(...)		do{}while(0)

#endif
#define DELAYSERVICE

/*********************
* EXPORTED TYPEDEFS  *
**********************/

//typedef and enum

/*******************
* EXPORTED DATA    *
********************/

//global external data 

//non static global

//static global

/********************************
* EXPORTED FUNCTIONS PROTOTYPES *
*********************************/

/*--------------------------------------------------------------------
 * Function_Name
 *
 * Description:
 *    ...............................................
 *    .......................................
 *
 * Arguments:
 *    Parameter1: IN, .......
 *    Parameter2: IN, .......
 *    Parameter3: OUT, .......
 *
 * Return Value: ...........
 *
 *------------------------------------------------------------------*/
 





#endif /*__LLD_VBI_M3327_ATSC_DTVCC_H__ */
